
import React, { createContext, useReducer } from 'react'
import { fromJS } from 'immutable'
export const CategoryDataContext = createContext({})



export const CHANGE_ALPHA = 'change_alpha';
export const CHANGE_CATEGORY = 'change_category';
const reducer = (state, actions) => {
  switch (actions.type) {
    case CHANGE_ALPHA:
      return state.set('alpha', actions.data);
    case CHANGE_CATEGORY:
      return state.set('category', actions.data)
    default:
      return state
  }
}
const Data = (props) => {

  const [data, dispatch] = useReducer(reducer, fromJS({
    category: '',
    alpha: ""
  }))
  return <CategoryDataContext.Provider value={{ data, dispatch }}>{props.children}</CategoryDataContext.Provider>
}
export {
  Data
}